KTIJ-26211: IDEA: On selecting it highlight the call accepting it's in lambda #3472
KTIJ-26211: IDEA: On selecting it highlight the call accepting it's in lambda #3472kshulzh wants to merge 1 commit intoJetBrains:masterfrom
it highlight the call accepting it's in lambda #3472Conversation
...-shared/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightImplicitItHandlerFactory.kt
Outdated
Show resolved
Hide resolved
|
Thanks a lot for the contribution 🙏 While task describe the intention, it does not describe all requirements. Consistency and easy way for observabilityWhen you place a caret to the
When you place a caret to any of that expressions, e.g. corresponding Similar behaviour you can observe with Therefore, I would like to have expected consistency in behaviour. In the same time it looks like we could start highlighting too much - that's another topic where we have IntelliJ platform limitations - there are only two types of such highlighting - for TestsTests are crucial part of development. I would recommend to take a look into this commit e0471e0 as inspiration point how to make tests. In short: we use so-called test-data to describe our functional requirements. For exit points we use |
Hello @vladimirdolzhenko, What can I do?
|
|
Hey @kshulzh ,
I think that's enough. Thanks a lot |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b520e15. Configure here.
|
|
||
|
|
||
| fun KtNameReferenceExpression.getLambdaFunctionLiteralByNameReference(): KtFunctionLiteral? { | ||
| val lambda = ((this.parent as? KtCallExpression)?.lastChild as? KtLambdaArgument)?.getLambdaExpression() ?: return null |
There was a problem hiding this comment.
Fragile lastChild instead of idiomatic lambdaArguments accessor
Medium Severity
getLambdaFunctionLiteralByNameReference uses lastChild as? KtLambdaArgument to locate the trailing lambda argument of a KtCallExpression. PsiElement.getLastChild() returns the literal last child node in the PSI tree, which can include whitespace or error elements. The rest of the codebase consistently uses the type-safe KtCallExpression.lambdaArguments property for this purpose (e.g., in symbolUtils.kt, KotlinExpressionMover.kt, ExpectedExpressionMatcher.kt). Using lambdaArguments.singleOrNull() would be more robust and consistent with existing patterns.
Reviewed by Cursor Bugbot for commit b520e15. Configure here.
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
|
Hello @vladimirdolzhenko, I tried to add tests and highlight for implicit "its" in case when cursor on lambda`s name |






The suggestion is to highlight effective function call with caret on it.




Here my first contribute I tried to follow your instructions
task
Note
Medium Risk
Touches editor highlight-usages behavior and adds extra PSI walking and analysis checks, which could affect highlighting correctness/performance in nested-lambda edge cases.
Overview
When the caret is on an implicit
it, the highlight-usages handler now also highlights the call expression that provides the lambda argument (in addition to theitoccurrences), and avoids incorrectly highlighting through nested lambdas whereitis shadowed or reintroduced.This is implemented by extending implicit-lambda utilities to detect implicit-
itlambdas from PSI (getLambdaFunctionLiteralByNameReference,getImplicitItLambdaParameterSymbol), updatingKotlinHighlightImplicitItHandlerFactoryto use the new detection and to add the call-site occurrence, registering the handler for K2, and adding shared K1/K2 test coverage plus test-generator wiring and new test data undertestData/implicitIt.Reviewed by Cursor Bugbot for commit b520e15. Bugbot is set up for automated code reviews on this repo. Configure here.